﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="waterFix.aspx.cs" Inherits="MxWeiXinPF.Web.weixin.jiaoshuifei.waterFix" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

    <link href="css/weui.min.css?v=2" rel="stylesheet" />
    <link href="css/jquery-weui.min.css" rel="stylesheet" />
    <link href="css/demos.css" rel="stylesheet" />
    <title>报修报漏</title>
</head>
<body ontouchstart>
 

    <div class="weui-cells">
        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd">
                <label for="" class="weui-label">类型</label>
            </div>
            <div class="weui-cell__bd">
                <select class="weui-select" name="select2" id="fixType">
                    <option selected="" value="报修">报修</option>
                    <option value="报漏">报漏</option>
                </select>
            </div>
        </div>

    </div>

    <div class="weui-cells weui-cells_form">
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label">联系人</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" id="username" placeholder="联系人" />
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label">电话</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" placeholder="请输入电话" id="phone" />
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <label class="weui-label">地址</label>
            </div>
            <div class="weui-cell__bd">
                <input class="weui-input" placeholder="请输入地址" id="address" />
            </div>
        </div>
    </div>
    <div class="weui-cells__title">情况说明</div>
    <div class="weui-cells weui-cells_form">
        <div class="weui-cell">
            <div class="weui-cell__bd ">
                <textarea class="weui-textarea" placeholder="请输入情况说明" id="remark" rows="3"></textarea>

            </div>
        </div>
    </div>


    <div class="weui-cells weui-cells_form">
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <div class="weui-uploader">
                    <div class="weui-uploader__hd">
                        <p class="weui-uploader__title">图片上传</p>
                         
                    </div>
                    <div class="weui-uploader__bd">
                        <ul class="weui-uploader__files" id="uploaderFiles">
                            <li class="weui-uploader__file" style="background-image: url(/images/noneimg.jpg)" id="uploadImg"></li>

                        </ul>
                        <div class="weui-uploader__input-box">
                            <input id="uploaderInput" class="weui-uploader__input" type="file" accept="image/jpg,image/jpeg,image/png,image/gif" multiple="" onchange="fileUpload()">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <input type="hidden" id="imgFile" />

     <div class='demos-content-padded'>

        <a class="weui-btn weui-btn_primary" href="javascript:" id="showTooltips" onclick="bind()">提交</a>
    </div>
      
    <script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="js/jquery-weui.js"></script>

    <script src="js/helper_min.js"></script>
    <script src="js/main.js"></script>

    <script>
        //绑定用户号
        function bind() {

            var fixType = $("#fixType").val();
            var username = $("#username").val();
            var phone = $("#phone").val();
            var address = $("#address").val();
            var remark = $("#remark").val();

            if (fixType == null || fixType == "") {

                $.toptip('请选择报修类型');
              
                retturn;
            }
            if (username == null || username == "") {
                $.toptip('请输入联系人');
               
                retturn;
            }
            if (phone == null || phone == "") {
                $.toptip('请输入电话');
 
                retturn;
            }
            if (address == null || address == "") {
               
                $.toptip('请输入地址');
                retturn;
            }
            //验证通过
            $.ajax({
                type: "post",
                url: "jsf_bindOne.ashx",
                data: { fixType: fixType, username: username, phone: phone, address: address, remark: remark, actionType: "fixApply", wid: '<%=wid%>', imgFile: $("#imgFile").val() ,openid:'<%=openid%>'},
                beforeSend: function () {
                   
                    $.showLoading();
                },
                success: function (data) {
                    if (data.succuss == 1) {
                        $.hideLoading();
                        $.alert("提交成功，请等待我们处理。", function () {
                            //点击确认后的回调函数
                            window.location.href = "index.aspx?wid=<%=wid%>";
                        });
                    }
                    else {
                        $.hideLoading();
                        $.toptip(data.msg);
                        
                    }
                }
            });
        }

        //上传图片
        function fileUpload() {
           
　
            window.ajax2("../../tools/upload_ajax.ashx", {
                type: "POST",
                async: true,
                data: { Filedata: $("#uploaderInput").get(0).files[0] },
                timeout: 10000 * 6,
                callback: function (data) {
                    if (data.status == 1) {
                       　

                        $("#uploadImg").css("background-image", "url(" + data.path + ")");
                        $("#imgFile").val(data.path);

                        $.toptip(data.msg,'success');
                    }
                    else {
                        $.toptip(data.msg);
                    }
                },
            });


        }
         
    </script>

</body>
</html>
